Skip to content

Add delegate support for agent users on issues#172

Open
shanelindsay wants to merge 4 commits intoschpet:mainfrom
shanelindsay:feat/issue-delegate-support
Open

Add delegate support for agent users on issues#172
shanelindsay wants to merge 4 commits intoschpet:mainfrom
shanelindsay:feat/issue-delegate-support

Conversation

@shanelindsay
Copy link

Summary

  • add --delegate to linear issue create and linear issue update
  • map agent delegation to Linear's delegateId instead of overloading assigneeId
  • reject app users passed to --assignee with a clear suggestion to use --delegate
  • document the new flag in docs/usage.md
  • add issue create/update tests for delegate success and app-user rejection
  • make the mock Linear server bind an ephemeral port so the snapshot tests do not collide

Why

Linear now distinguishes between human assignees and agent delegates. Without explicit delegate support, assigning an app user can look accepted while not expressing the correct model. This change makes the CLI reflect that distinction directly.

Verification

  • mise x deno@2 -- deno task codegen
  • mise x deno@2 -- deno lint src/commands/issue/issue-create.ts src/commands/issue/issue-update.ts src/utils/linear.ts test/utils/mock_linear_server.ts test/commands/issue/issue-create.test.ts test/commands/issue/issue-update.test.ts
  • mise x deno@2 -- deno fmt --check src/commands/issue/issue-create.ts src/commands/issue/issue-update.ts src/utils/linear.ts test/utils/mock_linear_server.ts test/commands/issue/issue-create.test.ts test/commands/issue/issue-update.test.ts docs/usage.md test/commands/issue/__snapshots__/issue-create.test.ts.snap test/commands/issue/__snapshots__/issue-update.test.ts.snap
  • mise x deno@2 -- deno test --allow-all --quiet test/commands/issue/issue-update.test.ts test/commands/issue/issue-create.test.ts

Note

Repo-wide deno task check still reports many pre-existing type errors outside this patch, so verification here is scoped to the touched area.

Copilot AI review requested due to automatic review settings March 11, 2026 11:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class agent delegation support to the linear issue create / linear issue update CLI commands by introducing a --delegate flag, resolving delegation to Linear’s delegateId, and enforcing that app users aren’t assigned via --assignee.

Changes:

  • Add --delegate flag to issue create/update and map it to delegateId (with validation that --assignee is human-only and --delegate is app-only).
  • Extend user lookup to return { id, app, ... } so commands can distinguish app vs human users.
  • Update docs + snapshot tests and make the mock Linear server bind an ephemeral port to avoid test collisions.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/utils/linear.ts Introduces lookupUser() returning user metadata (incl. app) and rebuilds lookupUserId() on top of it.
src/commands/issue/issue-create.ts Adds --delegate, validates human/app usage, and passes delegateId into issue creation input.
src/commands/issue/issue-update.ts Adds --delegate, validates human/app usage, and passes delegateId into issue update input.
test/utils/mock_linear_server.ts Switches mock server to bind an ephemeral port and records the actual port via onListen.
test/commands/issue/issue-create.test.ts Adds snapshot coverage for delegate happy path + assignee app-user rejection; updates viewer mock fields.
test/commands/issue/issue-update.test.ts Adds snapshot coverage for delegate happy path + assignee app-user rejection; updates viewer mock fields.
test/commands/issue/__snapshots__/issue-create.test.ts.snap Updates help output and adds snapshots for new delegate/error cases.
test/commands/issue/__snapshots__/issue-update.test.ts.snap Updates help output and adds snapshots for new delegate/error cases.
docs/usage.md Documents the new --delegate flag usage for create/update.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +31 to +36
this.server = Deno.serve({
hostname: "127.0.0.1",
port: 0,
onListen: ({ port }) => {
this.port = port
},
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server is bound to hostname: "127.0.0.1", but getEndpoint() (later in this file) still uses http://localhost:.... On systems where localhost resolves to IPv6 first, clients may try ::1 and fail to connect. Consider returning http://127.0.0.1:${port}/graphql (or binding the server to localhost/::1) to keep the bind address and endpoint consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +37
onListen: ({ port }) => {
this.port = port
},
}, (request) => {
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start() still relies on a fixed setTimeout later to wait for the server to be ready. Since you already use onListen, it would be more deterministic to await a promise resolved from onListen (and drop the arbitrary sleep) so tests are less flaky and start faster on slow CI runners.

Copilot uses AI. Check for mistakes.
Comment on lines +741 to +748
if (!resolvedDelegate.app) {
throw new ValidationError(
`Cannot use --delegate with human user '${delegate}'`,
{
suggestion:
`Use --assignee ${delegate} to assign the issue to a human user.`,
},
)
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new validation that rejects using --delegate with a human user (!resolvedDelegate.app) isn’t covered by a snapshot test in this PR. Add a test case that passes --delegate with a non-app user and asserts the failure message/suggestion, similar to the new app-user rejection tests for --assignee.

Copilot uses AI. Check for mistakes.
Comment on lines +205 to +212
if (!resolvedDelegate.app) {
throw new ValidationError(
`Cannot use --delegate with human user '${delegate}'`,
{
suggestion:
`Use --assignee ${delegate} to assign the issue to a human user.`,
},
)
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new validation that rejects using --delegate with a human user (!resolvedDelegate.app) isn’t covered by a snapshot test. Add an issue update test that uses --delegate with a human user and asserts the error + suggestion output, mirroring the new app-user rejection test for --assignee.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants